import 'package:flutter/material.dart';
import '/base/view.dart';
import '/pages/home/view.dart';
import '/pages/my/view.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../modules/drawer/drawer.dart';
import 'logic.dart';
import 'package:get/get.dart';

class MainPage extends StatelessWidget {
  final logic = Get.put(MainLogic());
  final state = Get.find<MainLogic>().state;

  @override
  Widget build(BuildContext context) {
    return MyBody();
  }
}

class MyBody extends StatefulWidget {

  @override
  State<MyBody> createState() => _MyBodyState();
}

class _MyBodyState extends State<MyBody> with SingleTickerProviderStateMixin {
  int currentIndex = 0;
  List<StatelessWidget> children = [HomePage(), MyPage()];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color(0xffEFF8FF),
      body: children[currentIndex],
      endDrawer: const DrawerPage(),
      bottomNavigationBar: BottomNavigationBar(
        selectedFontSize: 12.w,
        unselectedFontSize: 12.w,
        currentIndex: currentIndex,
        onTap: (index) {
          setState(() {
            currentIndex = index;
          });
        },
        selectedItemColor: Color(0xFF00A4F5),
        unselectedItemColor: Color(0xFF91A2B5),
        items: [
          BottomNavigationBarItem(
              label: "首页",
              activeIcon: Image.asset(
                "images/main/home_true.png",
                width: 32.w,
                height: 32.w,
              ),
              icon: Image.asset(
                "images/main/home_false.png",
                width: 32.w,
                height: 32.w,
              )),
          BottomNavigationBarItem(
              label: "我的",
              activeIcon: Image.asset(
                "images/main/my_true.png",
                width: 32.w,
                height: 32.w,
              ),
              icon: Image.asset(
                "images/main/my_false.png",
                width: 32.w,
                height: 32.w,
              )),
        ],
      ),
    );
  }
}
